home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / demos / OpenGL / stonehenge / Ellipse.c++ < prev    next >
C/C++ Source or Header  |  1996-11-11  |  4KB  |  134 lines

  1. /*
  2.  * (c) Copyright 1993, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for
  6.  * any purpose and without fee is hereby granted, provided that the above
  7.  * copyright notice appear in all copies and that both the copyright notice
  8.  * and this permission notice appear in supporting documentation, and that
  9.  * the name of Silicon Graphics, Inc. not be used in advertising
  10.  * or publicity pertaining to distribution of the software without specific,
  11.  * written prior permission.
  12.  *
  13.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  14.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  16.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  17.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  18.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  19.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  20.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  21.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  22.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  23.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  24.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  25.  *
  26.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
  27.  * Use, duplication, or disclosure by the Government is subject to
  28.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  29.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  30.  * clause at DFARS 252.227-7013 and/or in similar or successor
  31.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  32.  * Unpublished-- rights reserved under the copyright laws of the
  33.  * United States.  Contractor/manufacturer is Silicon Graphics,
  34.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  35.  *
  36.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  37.  */
  38. #include <GL/glu.h>
  39. #include <GL/glx.h>
  40.  
  41. #include <stdio.h>
  42.  
  43. #include "Ellipse.h"
  44.  
  45. Ellipse::Ellipse()
  46. {
  47.   Point sar_dim, lin_dim;
  48.  
  49.   sar_dim.set(.3, .5, 1.2);
  50.   lin_dim.set(.3, 1.2, .2);
  51.  
  52.   sarcens[0].set_dimensions(sar_dim);
  53.   lintels[0].set_dimensions(lin_dim);
  54.   sarcens[0].translate(5, 0, sar_dim.pt[2]);
  55.   lintels[0].translate(4.9, 0, 2.*sar_dim.pt[2] + lin_dim.pt[2]);
  56.   copy_zero();
  57.  
  58.   sarcens[0].rotate_self_aboutz(17);
  59.   sarcens[1].rotate_self_aboutz(33);
  60.   lintels[0].rotate_self_aboutz(25);
  61.  
  62.   sarcens[2].rotate_self_aboutz(-17);
  63.   sarcens[3].rotate_self_aboutz(-33);
  64.   lintels[1].rotate_self_aboutz(-25);
  65.  
  66.   sarcens[4].rotate_self_aboutz(197);
  67.   sarcens[5].rotate_self_aboutz(213);
  68.   lintels[2].rotate_self_aboutz(205);
  69.  
  70.   sarcens[6].rotate_self_aboutz(-197);
  71.   sarcens[7].rotate_self_aboutz(-213);
  72.   lintels[3].rotate_self_aboutz(-205);
  73. }  
  74.   
  75. void Ellipse::erode(float p)
  76. {
  77.   int i;
  78.  
  79.   for (i = 0; i < nsarcens; i++) sarcens[i].erode(p);
  80.   for (i = 0; i < nlintels; i++) lintels[i].erode(p);
  81. }
  82.  
  83. void Ellipse::draw()
  84. {
  85.   glPushMatrix();
  86.   glScalef(1, 1.1, 1);
  87.   draw_sarcens();
  88.   draw_lintels();
  89.   glPopMatrix();
  90. }
  91.  
  92. void Ellipse::draw_sarcens()
  93. {
  94.   int i;
  95.   for (i = 0; i < nsarcens; i++) sarcens[i].draw();
  96. }
  97.  
  98. void Ellipse::draw_lintels()
  99. {
  100.   int i;
  101.   for (i = 0; i < nlintels; i++) lintels[i].draw();
  102. }
  103.  
  104. void Ellipse::draw_shadow(Point dlight, GLfloat blur,
  105.               Color color, Color diffuse)
  106. {
  107.   draw_sarcens_shadows(dlight, blur, color, diffuse);
  108.   draw_lintels_shadows(dlight, blur, color, diffuse);
  109. }
  110.  
  111. void Ellipse::draw_sarcens_shadows(Point dlight, GLfloat blur,
  112.                    Color color, Color diffuse)
  113. {
  114.   int i;
  115.   for (i = 0; i < nsarcens; i++) 
  116.     sarcens[i].draw_shadow(dlight, blur, color, diffuse);
  117. }
  118.  
  119. void Ellipse::draw_lintels_shadows(Point dlight, GLfloat blur,
  120.                    Color color, Color diffuse)
  121. {
  122.   int i;
  123.   for (i = 0; i < nlintels; i++) 
  124.     lintels[i].draw_shadow(dlight, blur, color, diffuse);
  125. }
  126.  
  127. void Ellipse::copy_zero()
  128. {
  129.   int i;
  130.  
  131.   for (i = 1; i < nsarcens; i++) sarcens[i] = sarcens[0];
  132.   for (i = 1; i < nlintels; i++) lintels[i] = lintels[0];
  133. }
  134.